import request from "@/utils/requests/index";
import { RequestEnum, } from '@/enums/httpEnum'
import { EmployeeMould } from './types/index'
import { Response } from '@/api/types/index'

enum Api {
  // 分页搜索员工
  GET_EMPLOYEE_LIST_PATH = '/admin/employee/page',
  // 新增、编辑员工
  ADD_EDIT_EMPLOYEE_PATH = '/admin/employee'
}

export function getEmployeeListReq(data: EmployeeMould.IGetEmployeeListReq) {
  // return request.request<Response<EmployeeMould.IEmployeeListRes>>({
  return request.request({
    method: RequestEnum.GET,
    url: Api.GET_EMPLOYEE_LIST_PATH +
      `?name=${data.name}&page=${data.page}&pageSize=${data.pageSize}`,
  })
}

export function addEmployeeReq(data: EmployeeMould.IAddOrEditEmployee) {
  return request.request({
    method: RequestEnum.POST,
    url: Api.ADD_EDIT_EMPLOYEE_PATH,
    data
  })
}

export function editEmployeeReq(data: EmployeeMould.IAddOrEditEmployee) {
  return request.request({
    method: RequestEnum.PUT,
    url: Api.ADD_EDIT_EMPLOYEE_PATH,
    data
  })
}
